package com.example.graduatedesigned.http;

import io.reactivex.Observable;
import com.example.graduatedesigned.bean.DataResponse;
import com.example.graduatedesigned.bean.DeviceItem;
import com.example.graduatedesigned.bean.DeviceStatus;
import com.example.graduatedesigned.bean.HistoryBean;
import com.example.graduatedesigned.bean.LedProductRequest;
import com.example.graduatedesigned.bean.ProductRequest;
import java.util.List;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface ApiService {
    @GET("thingmodel/query-device-property")
    Observable<DataResponse<List<DeviceItem>>> getDeviceInfo(
            @Query("product_id") String productId,
            @Query("device_name") String deviceName,
            @Header("Authorization") String header
    );

    @GET("device/status-history")
    Observable<DataResponse<DeviceStatus>> getDeviceStatus(
            @Query("product_id") String productId,
            @Query("device_name") String deviceName,
            @Header("Authorization") String header,
            @Query("start_time") long startTime,
            @Query("end_time") long endTime,
            @Query("limit") int limit
    );

    @POST("thingmodel/set-device-property")
    Call<DataResponse> setDeviceStatus(
            @Header("Authorization") String header,
            @Body ProductRequest productRequest
    );

    @POST("thingmodel/set-device-property")
    Call<DataResponse> setLedDeviceStatus(
            @Header("Authorization") String header,
            @Body LedProductRequest ledProductRequest
    );

    @GET("thingmodel/query-device-property-history")
    Call<DataResponse<HistoryBean>> getDeviceHistory(
            @Query("product_id") String productId,
            @Query("device_name") String deviceName,
            @Header("Authorization") String header,
            @Query("start_time") long startTime,
            @Query("end_time") long endTime,
            @Query("identifier") String id
    );
}
